<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
        var singleton = function () {
            var arr = [1,2,3];
            var app = {};
            app.getLength= function () {
                return arr.length;
            },

            app.addData= function (data) {
                arr.push(data)
                console.log(arr);
            }

            return app;
        }

        var singletonMethods = singleton();
        console.log(singletonMethods.getLength()); //3
        singletonMethods.addData('hou') //[1, 2, 3, "hou"]
    </script>
</body>
</html>
